package cn.hxzy.course.service.impl;

import cn.hxzy.common.domain.FileInfo;
import cn.hxzy.course.mapper.FileInfoMapper;
import cn.hxzy.course.service.FileInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> implements FileInfoService  {
    @Autowired
    private FileInfoMapper fileInfoMapper;

    @Override
    public int insertFileInfo(FileInfo fileInfo) {
        int insert = fileInfoMapper.insert(fileInfo);
        return insert;
    }

    @Override
    public List<FileInfo> selectFileInfo(String infoName, Integer courseId) {
        List<FileInfo> fileInfos = fileInfoMapper.selectFileInfo(infoName,1);
        if (fileInfos!=null) {
            return fileInfos;
        }
        return null;
    }

    @Override
    public List<FileInfo> selectFileInfoNum(Integer sectionId) {
        List<FileInfo> fileInfos = fileInfoMapper.selectFileInfoNum(sectionId);
        return fileInfos;
    }

    @Override
    public double selectCount(Long courseId) {
        double num = fileInfoMapper.selectCount(courseId);
        return num;
    }

    @Override
    public int deleteFileInfo(Integer infoId) {
        int i = fileInfoMapper.deleteFileInfo(infoId);
        return i;
    }
}
